package com.jetbrains.rider.aspire.util

const val DEBUG_SESSION_TOKEN = "DEBUG_SESSION_TOKEN"
const val DEBUG_SESSION_PORT = "DEBUG_SESSION_PORT"
const val DEBUG_SESSION_SERVER_CERTIFICATE = "DEBUG_SESSION_SERVER_CERTIFICATE"
const val DCP_INSTANCE_ID_PREFIX = "DCP_INSTANCE_ID_PREFIX"
const val ASPNETCORE_URLS = "ASPNETCORE_URLS"

const val ASPIRE_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS = "ASPIRE_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS"
const val DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS = "DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS"
fun Map<String, String>.getAspireDashboardUnsecuredAllowAnonymous() : Boolean =
    (get(ASPIRE_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS) ?: get(DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS))
        ?.equals("true", true) == true

const val ASPIRE_DASHBOARD_FRONTEND_BROWSERTOKEN = "ASPIRE_DASHBOARD_FRONTEND_BROWSERTOKEN"
const val DOTNET_DASHBOARD_FRONTEND_BROWSERTOKEN = "DOTNET_DASHBOARD_FRONTEND_BROWSERTOKEN"
fun Map<String, String>.getAspireDashboardFrontendBrowserToken() =
    get(ASPIRE_DASHBOARD_FRONTEND_BROWSERTOKEN) ?: get(DOTNET_DASHBOARD_FRONTEND_BROWSERTOKEN)

const val ASPIRE_DASHBOARD_RESOURCESERVICE_APIKEY = "ASPIRE_DASHBOARD_RESOURCESERVICE_APIKEY"
const val DOTNET_DASHBOARD_RESOURCESERVICE_APIKEY = "DOTNET_DASHBOARD_RESOURCESERVICE_APIKEY"
fun Map<String, String>.getAspireDashboardResourceServiceApiKey() =
    get(ASPIRE_DASHBOARD_RESOURCESERVICE_APIKEY) ?: get(DOTNET_DASHBOARD_RESOURCESERVICE_APIKEY)

const val ASPIRE_ALLOW_UNSECURED_TRANSPORT = "ASPIRE_ALLOW_UNSECURED_TRANSPORT"
fun Map<String, String>.getAspireAllowUnsecuredTransport() : Boolean =
    get(ASPIRE_ALLOW_UNSECURED_TRANSPORT)?.equals("true", true) == true

const val ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL = "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL"
const val DOTNET_RESOURCE_SERVICE_ENDPOINT_URL = "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL"
fun Map<String, String>.getAspireResourceServiceEndpointUrl() =
    get(ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL) ?: get(DOTNET_RESOURCE_SERVICE_ENDPOINT_URL)

const val ASPIRE_CONTAINER_RUNTIME = "ASPIRE_CONTAINER_RUNTIME"
const val DOTNET_ASPIRE_CONTAINER_RUNTIME = "DOTNET_ASPIRE_CONTAINER_RUNTIME"
fun Map<String, String>.getAspireContainerRuntime() =
    get(ASPIRE_CONTAINER_RUNTIME) ?: get(DOTNET_ASPIRE_CONTAINER_RUNTIME)

const val ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL = "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL"
const val DOTNET_DASHBOARD_OTLP_ENDPOINT_URL = "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL"
fun Map<String, String>.getAspireDashboardOtlpEndpointUrl() =
    get(ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL) ?: get(DOTNET_DASHBOARD_OTLP_ENDPOINT_URL)